package lib.quasar.widget.chart.paint;

import android.graphics.Color;
import android.graphics.CornerPathEffect;
import android.graphics.Paint;

import lib.quasar.util.DimenUtil;

/**
 * description: 画笔
 * created by kalu on 2017/11/12 3:05
 */
public final class StockPaint {

    private final static Paint mPaint = new Paint();
    public static float LiNE_WIDTH = DimenUtil.dp2px(1.5f);
    public static float DASH_WIDTH = DimenUtil.dp2px(0.8f);
    public static float TEXT_AXIS_SIZE = DimenUtil.sp2px(10.5f);
    public static float TEXT_UNIT_SIZE = DimenUtil.sp2px(12.2f);
    public static float TEXT_HINT_SIZE = DimenUtil.sp2px(13.2f);
    public static float DOT_RADIUS = DimenUtil.dp2px(5f);

    public static final int RED = Color.parseColor("#ea5757");
    public static final int WHITE = Color.WHITE;
    public static final int GREEN = Color.parseColor("#13ad67");
    public static final int ORANGE = Color.parseColor("#ff9e21");
    public static final int BLUE = Color.parseColor("#1296db");
    public static final int BLACK = Color.BLACK;

    public static Paint getRectPaint() {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(BLUE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);

        return mPaint;
    }

    public static Paint getRectPaint(int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(color);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);

        return mPaint;
    }

    public static Paint getAxisPaint() {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(Color.WHITE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(LiNE_WIDTH);

        return mPaint;
    }

    public static Paint getAxisPaint(int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(true);
        mPaint.setColor(color);
        mPaint.setTextSize(TEXT_AXIS_SIZE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(LiNE_WIDTH);

        return mPaint;
    }

    public static Paint getAxisPaint(Paint.Align align, int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(true);
        mPaint.setColor(color);
        mPaint.setTextAlign(align);
        mPaint.setTextSize(TEXT_AXIS_SIZE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(0f);

        return mPaint;
    }

    public static Paint getLinePaint() {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(Color.WHITE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(LiNE_WIDTH);
        mPaint.setPathEffect(new CornerPathEffect(5f)); // 拐点顺滑

        return mPaint;
    }

    public static Paint getLinePaint(int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(color);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(LiNE_WIDTH);
        mPaint.setPathEffect(new CornerPathEffect(5f)); // 拐点顺滑

        return mPaint;
    }

    public static Paint getDashPaint(int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(color);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(DASH_WIDTH);

        return mPaint;
    }

    public static Paint getHintPaint() {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(true);
        mPaint.setColor(Color.WHITE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setTextSize(TEXT_HINT_SIZE);
        // mPaint.setPathEffect(new CornerPathEffect(5f)); // 拐点顺滑

        return mPaint;
    }

    public static Paint getHintPaint(int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(true);
        mPaint.setColor(color);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setTextSize(TEXT_HINT_SIZE);
        // mPaint.setPathEffect(new CornerPathEffect(5f)); // 拐点顺滑

        return mPaint;
    }

    public static Paint getUnitPaint() {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(WHITE);
        mPaint.setStrokeWidth(0f);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setTextSize(TEXT_UNIT_SIZE);
        // mPaint.setPathEffect(new CornerPathEffect(5f)); // 拐点顺滑

        return mPaint;
    }

    public static Paint getUnitPaint(int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(color);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setStrokeWidth(0f);
        mPaint.setTextSize(TEXT_UNIT_SIZE);
        // mPaint.setPathEffect(new CornerPathEffect(5f)); // 拐点顺滑

        return mPaint;
    }

    public static Paint getDotPaint() {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(Color.WHITE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(0f);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setTextSize(0f);
        // mPaint.setPathEffect(new CornerPathEffect(5f)); // 拐点顺滑

        return mPaint;
    }

    public static Paint getDotPaint(int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(false);
        mPaint.setColor(color);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(0f);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setTextSize(0f);
        // mPaint.setPathEffect(new CornerPathEffect(5f)); // 拐点顺滑

        return mPaint;
    }

    public static Paint getAxisTextPaint(Paint.Align align, int color) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(true);
        mPaint.setColor(color);
        mPaint.setTextAlign(align);
        mPaint.setTextSize(TEXT_AXIS_SIZE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(0f);

        return mPaint;
    }

    public static Paint getAxisTextPaint(Paint.Align align, int color, float textsize) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(true);
        mPaint.setColor(color);
        mPaint.setTextAlign(align);
        mPaint.setTextSize(textsize);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeWidth(0f);

        return mPaint;
    }
}
